package com.lecture.javamode.singleton;

public class Singleton {

    private Singleton() {
        if (SingletonHolder.singleton != null) {
            throw new RuntimeException("不能创建");
        }
        System.out.println("私有构造");
    }


    private static final class SingletonHolder {
        static final Singleton singleton = new Singleton();
    }

    public static Singleton getInstance() {
        return SingletonHolder.singleton;
    }

    public void print() {
        System.out.println("shuch");
    }
}
